from typing import List


class Solution:
    def maxProfit(self, prices: List[int]) -> int:
        inf = int(1e9)
        minprice = inf
        maxprofit = 0
        for price in prices:
            maxprofit = max(price - minprice, maxprofit)
            minprice = min(price, minprice)
        return maxprofit


if __name__ == '__main__':
    prices = [7, 1, 5, 3, 6, 4]
    prices2 = [7, 6, 4, 3, 1]
    s = Solution()
    print(s.maxProfit(prices2))
